﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KingRoad.EPM.SafetyManagementBLL.Domain;
using KingRoad.EPM.SafetyManagementEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.SafetyManagementDAL.ScmAssessmentunitService;


namespace KingRoad.EPM.SafetyManagementBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/2/5 14:21:47
    /// </summary> 
    public class ScmAssessmentunitUIRule
    {
        private readonly IScmAssessmentunitService _scmAssessmentunitService;
        
        
        public ScmAssessmentunitUIRule(){}
        
        /// <summary> 
        /// construct function... 
        /// </summary> 
        public ScmAssessmentunitUIRule(IScmAssessmentunitService  scmAssessmentunitService)
        {
           _scmAssessmentunitService=scmAssessmentunitService;
        }
        /// <summary>
        /// 根据安全考核主键获取被考核单位信息
        /// </summary>
        /// <param name="Sa_ID">安全考核主键</param>
        /// <returns></returns>
        public List<ScmAssessmentunitInfo> GetAssessmentunitBySa_ID(string sa_id)
        {
            string sql=" 1=1 ";
            if (sa_id != "")
                sql = " Sa_ID='" + sa_id + "' ";
            var list = _scmAssessmentunitService.GetEntityList(sql);
            return list;
        }
        /// <summary>
        /// 根据安全考核主键获取被考核单位信息
        /// </summary>
        /// <param name="id">被考核单位主键</param>
        /// <returns></returns>
        public ScmAssessmentunitInfo GetAssessmentunitInfo(Guid id)
        {
            var list = _scmAssessmentunitService.GetEntityById(id);
            return list;
        }
        /// <summary>
        /// 添加被考核单位信息
        /// </summary>
        /// <param name="info">被考核单位信息</param>
        /// <returns></returns>
        public int AddAssessmentunit(ScmAssessmentunitInfo info)
        {
            return _scmAssessmentunitService.InsertEntity(info);
        }
        /// <summary>
        /// 修改被考核单位信息
        /// </summary>
        /// <param name="info">被考核单位信息</param>
        /// <returns></returns>
        public int EditAssessmentunit(ScmAssessmentunitInfo info)
        {
            return _scmAssessmentunitService.UpdateEntity(info);
        }
        /// <summary>
        /// 根据考核主键删除被考核单位信息
        /// </summary>
        /// <param name="sa_id">安全考核主键</param>
        /// <returns></returns>
        public int DeleteAssessmentunitBySaID(string sa_id)
        {
            return _scmAssessmentunitService.DeleteAssessmentunitBySaID(sa_id);
        }
        /// <summary>
        /// 判断是否存在AssisId
        /// </summary>
        /// <param name="assisId"></param>
        /// <returns></returns>
        public bool IsExitAssistId(int assisId)
        {
            var strSql = String.Format(" Assist_ID={0} ", assisId);
            var list = _scmAssessmentunitService.GetEntityList(strSql);
            return list.Any();
        }
    }
}

